<?php

$id				= gpc_getIntPost("id",$id);
$oldUrl 		= gpc_getStringPost("oldUrl");
$name       	= gpc_getStringPost("Name");
$urlstring		= gpc_getStringPost("URL",$name);
$title			= gpc_getStringPost("Title",$name);
$address		= gpc_getStringPost("Address");
$phone		    = gpc_getStringPost("Phone");
$fax		    = gpc_getStringPost("Fax");
$email		    = gpc_getStringPost("Email");
$location		= gpc_getIntPost("Location");
$TypeId 		= gpc_getIntPost("TypeId");
$TypeId2 		= gpc_getIntPost("TypeId2");
$star		    = gpc_getIntPost("Star");
$HighLights     = gpc_getStringPost("HighLights");


$TopBottomOrder	= gpc_getIntPost("TopBottomOrder",-1);
$order 			= gpc_getIntPost("Order",-1);
$status 		= gpc_getIntPost("Status");
$sologan 		= gpc_getStringPost("Sologan");
$description 	= gpc_getStringPost("Description");
$intro			= gpc_getStringPost("Intro");
$Rates			= gpc_getStringPost("Rates");
$tag 			= gpc_getStringPost("Tag");

$metatitle 		= gpc_getStringPost("MetaTitle",$name);
$metakeywords 	= gpc_getStringPost("MetaKeywords");
$metadescription= gpc_getStringPost("MetaDescription",strip_tags($description));

$ImgIntro 		= gpc_getStringPost('ImgIntro');
$ImgBanner 		= gpc_getStringPost('ImgBanner');
$ImgBackground  = gpc_getStringPost('ImgBackground');
//------==============-------------------
$urlstring=Trim_Url($urlstring);
//check url:

if(empty($name))
{
	error_transfer("Name is empty. please go back!","opt=add");
}

$description = replace_pathlocal($description);
$intro		 = replace_pathlocal($intro);
$metadescription=strip_tags($metadescription);

CheckUrlString($urlstring,"tblhotel",$location);

$order=GetOrderForInsert($TopBottomOrder,$order,$location,"tblhotel");

if($act=="insert")
{
    //insert Hotel:
    $postdate   = date("Y-m-d");
    $poster     = getUserNamePost();

    $sql_insert = "insert into tblhotel
                (iParentId,cName,cUrlString,cAddress,cCity,cType,cPhone,cFax,cEmail,cWebsite,cDescription,cIntro,
                cImage,cBanner,cBackground,iStar,cGeneral,cServices,cFoodBeverage,iOrder,iStatus,dPostDate,cPoster,
                cMetaTitle,cMetaKeywords,cMetaDescription,cLanguage,iTypeId,iTypeId2,cRates,cHighLights)
            values('$location','$name','$urlstring','$address','$city','$type','$phone','$fax','$email','$website','$description','$intro',
                '$ImgIntro','$ImgBanner','$ImgBackground',$star,'$general','$services','$foodbeverage','$order','$status','$postdate','$poster',
                '$metatitle','$metakeywords','$metadescription','$language','$TypeId','$TypeId2','$Rates','$HighLights')";

    $dbsql->query($sql_insert);
    //-----------------------------------------------------

    $cActions = "Add Hotel : $name ";
    Insert_Tracking($cActions);

    page_transfer("Add Hotel Success !","id=$location");
}elseif($id>0)
{
    $sql_update = "update tblhotel SET ";
    $sql_update.= "iParentId            = '".$location."', ";
    $sql_update.= "cName                = '".$name."', ";
    $sql_update.= "cUrlString           = '".$urlstring."', ";
    $sql_update.= "cAddress             = '".$address."', ";
    $sql_update.= "cCity                = '".$city."', ";
    $sql_update.= "cType                = '".$type."', ";
    $sql_update.= "cPhone               = '".$phone."', ";
    $sql_update.= "cFax                 = '".$fax."', ";
    $sql_update.= "cWebsite             = '".$website."', ";
    $sql_update.= "cDescription         = '".$description."', ";
    $sql_update.= "cIntro               = '".$intro."', ";
    $sql_update.= "cRates               = '".$Rates."', ";
    $sql_update.= "cImage               = '".$ImgIntro."', ";
    $sql_update.= "cBanner              = '".$ImgBanner."', ";
    $sql_update.= "cBackground          = '".$ImgBackground."', ";
    $sql_update.= "iTypeId              = '".$TypeId."', ";
    $sql_update.= "iTypeId2             = '".$TypeId2."', ";
    $sql_update.= "iStar                = '".$star."', ";
    $sql_update.= "cGeneral             = '".$general."', ";
    $sql_update.= "cServices            = '".$services."', ";
    $sql_update.= "cFoodBeverage        = '".$foodbeverage."', ";
    $sql_update.= "cHighLights          = '".$HighLights."', ";
    if($order>0)
    {
        $sql_update.= "iOrder               = '".$order."', ";
    }
    $sql_update.= "iStatus              = '".$status."', ";
    $sql_update.= "cMetaTitle           = '".$metatitle."', ";
    $sql_update.= "cMetaKeywords        = '".$metakeywords."', ";
    $sql_update.= "cMetaDescription     = '".$metadescription."' ";
    $sql_update.= " where iId=$id ";

    $dbsql->query($sql_update);


    Insert_Tracking("Edit Hotel : $name ");
    page_transfer("Update Hotel Success !","id=$location");
}
?>
